﻿using System;
using System.Web.UI.WebControls;
using Controller;

public partial class Tagged : System.Web.UI.Page
{
    public static string _key;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            var key = Request.QueryString["Key"];
            if (!string.IsNullOrEmpty(key))
            {
                litKey.Text = key;
                _key = key;
                litTitlePage.Text = key;
                BindDataListTour(key);
                litKeyTintuc.Text = _key;
                BindDataListTintuc(key);
            }
        }
    }

    public void BindDataListTour(string key)
    {
        var controller = new VYC01Controller();
        var model = controller.GetByTag(key, 1);

        gvTourTagged.DataSource = model;
        gvTourTagged.DataBind();

    }
    protected void gv_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        gvTourTagged.PageIndex = e.NewPageIndex;
        BindDataListTour(_key);
    }

    /// <summary>
    /// Event OnSorting="gv_Sorting" on GridView
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void gv_Sorting(object sender, GridViewSortEventArgs e)
    {
        BindDataListTour(_key);
    }

    public void BindDataListTintuc(string key)
    {
        var controller = new VYC06Controller();
        var model = controller.GetByTag(key, 1);

        gvTintucTagged.DataSource = model;
        gvTintucTagged.DataBind();

    }
    protected void gv_PageIndexChanging1(object sender, GridViewPageEventArgs e)
    {
        gvTintucTagged.PageIndex = e.NewPageIndex;
        BindDataListTintuc(_key);
        litKeyTintuc.Text = _key;
    }

    /// <summary>
    /// Event OnSorting="gv_Sorting" on GridView
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void gv_Sorting1(object sender, GridViewSortEventArgs e)
    {
        BindDataListTintuc(_key);
    }
}